home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / ooav3 / ooavzip.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-05-22  |  1.9 KB  |  82 lines

  1. {
  2.         Object-Oriented Archive-viewer: ZIP-part
  3. }
  4.  
  5. Unit      OOAVZip;
  6.  
  7. Interface
  8.  
  9. Uses      Dos,OOAV;
  10.  
  11.  
  12. Type      ZFHeader=Record
  13.                      Signature                         :longint;
  14.                      Version,GPBFlag,Compress,Date,Time:word;
  15.                      CRC32,CSize,USize                 :longint;
  16.                      FNameLen,ExtraField               :word;
  17.                    end;
  18.  
  19.  
  20. type      PZipArchive=^TZipArchive;
  21.           TZipArchive=object(TGeneralArchive)
  22.                         constructor Init;
  23.                         procedure FindFirst(var sr:SearchRec);virtual;
  24.                         procedure FindNext(var sr:SearchRec);virtual;
  25.                       private
  26.                         Hdr:ZFHeader;
  27.                         procedure GetHeader(var sr:SearchRec);
  28.                       end;
  29.  
  30. implementation
  31.  
  32.  
  33. Const     SIG = $04034B50;                  { Signature }
  34.  
  35.  
  36. constructor TZipArchive.Init;
  37. begin
  38.   FillChar(Hdr,sizeof(Hdr),0);
  39. end;
  40.  
  41.  
  42. procedure TZipArchive.GetHeader(var sr:SearchRec);
  43. var       b:byte;
  44.           bc:word;
  45. begin
  46.   fillchar(sr,sizeof(sr),0);
  47.   if eof(_FArchive) then
  48.     exit;
  49.   BlockRead(_FArchive,Hdr,SizeOf(Hdr),bc);
  50.   if bc<>Sizeof(Hdr) then
  51.     exit;
  52. { Why checking for Hdr.FNamelen=0?
  53.   Because the comments inserted in a ZIP-file are at the last field }
  54.   if Hdr.FNameLen=0 then
  55.     exit;
  56.   sr.Name:='';
  57.   Repeat
  58.     BlockRead(_FArchive,b,1);
  59.     If b<>0 Then
  60.       sr.Name:=sr.Name+Chr(b);
  61.   Until (length(sr.Name)=Hdr.FNameLen) or (b=0);
  62.   if b=0 then
  63.     exit;
  64.   Seek(_FArchive,FilePos(_FArchive)+Hdr.CSize+Hdr.ExtraField);
  65.   sr.Size:=Hdr.USize;
  66.   sr.Time:=Hdr.Date+Hdr.Time*longint(256*256);
  67. end;
  68.  
  69.  
  70. Procedure TZipArchive.FindFirst(var sr:SearchRec);
  71. begin
  72.   GetHeader(sr);
  73. end;
  74.  
  75.  
  76. Procedure TZipArchive.FindNext(var sr:SearchRec);
  77. begin
  78.   GetHeader(sr);
  79. end;
  80.  
  81.  
  82. end.